﻿/*********************************
ProjectWindow
2017.09.12
libaojun
************************************ */

#ifndef _CONTROLPANEL_H_
#define _CONTROLPANEL_H_

#include "mainWidgetsAPI.h"
#include "ModuleBase/dockWidgetBase.h"
#include <QProcess>
#include <QListWidgetItem>

class PipelineObjTreeDockWidget;
class PipelineObjPropDockWidget;

namespace Ui
{
	class ControlPanel;
}
namespace GUI
{
	class MainWindow;
}
namespace DataProperty
{
	class DataBase;
}

namespace PostPlot
{
	class PlotTreeWidget;

}

namespace Post
{
	class PostTreeWidget;
	class PostTableWidget;
	class PostInfoWidget;
}

namespace MainWidget
{
	class PhysicsWidget;
	class MeshWidget;
	class GeometryTreeWidget;
	class PropertyTable;
	class PostTreeWidget;
	class PostTableWidget;
	class C3fdAnalysisWidget;
	class C3fdPostWidget;
	class C3fdGeomWidget;

	class MAINWIDGETSAPI ControlPanel : public ModuleBase::DockWidgetBase // public QDockWidget, public CModuleBase
	{
		Q_OBJECT
	public:
		ControlPanel(GUI::MainWindow *mainwindow);
		virtual ~ControlPanel();
		virtual void reTranslate() override;

		void setTabText(QWidget *w, QString text);

	signals:
		void updateActionStates();
		void sendMessage(QString);
		void showC3fdPostWidgetSig();

		void changeControlTab(QString);

	public:
		void updatePostWidget(QWidget *tree, QWidget *prop);
		void updatePostWidget();
		// 清空属性窗widget
		void clearWidget();
		// 根据配置信息更新开放接口
		void registerEnabledModule();
		// 添加窗口
		void addTabWidgetPlugin(QWidget *w, QString name);
		// 移除窗口
		void removeTabWidgetPlugin(QWidget *w);
		// 设置当前窗口
		void setCurrentWidget(QWidget *w);

		Post::PostTreeWidget *getPostTreeWidget();

	public slots:
		// 鼠标点击事件，包括左键单击双击及右键菜单
		virtual void on_TreeMouseEvent(int evevntType, QTreeWidgetItem *item, int proID);
		// 更新属性框
		void updataPropertyTab(DataProperty::DataBase *popList);
		void updateC3fdRowTreeSlot();
		void updateMeshRowParameterTab(QTreeWidgetItem *rowItem);
		void updateSolveParameterTab(QTreeWidgetItem *item, bool);
		void updatePostParameterTab(QWidget *, QString);
		// 设置属性窗当前页
		void changePropTabByProjectPage(int index);
		// 更新属性窗体
		void updataParaWidget(QWidget *w);

		void updateChildWidget();

	private:
		void Init();
		void resizeEvent(QResizeEvent *);
		// 		void fillProp();
		// 		void fillPara();

	protected:
		Ui::ControlPanel *_ui{};

		C3fdGeomWidget *_c3fdGeomWidget{};
		C3fdAnalysisWidget *_c3fdAnalysisWidget{};
		C3fdPostWidget *_c3fdPostWidget{};
		PhysicsWidget *_physicsWidget{};
		GeometryTreeWidget *_geometryWidget{};
		MeshWidget *_meshWidget{};
		PropertyTable *_propTable{};

		QWidget *_postTree{};
		QWidget *_postProp{};
		QWidget *_c3fdControlWidget = nullptr;
		DataProperty::DataBase *_data{};

		QWidget *_paraWidget{};

		QHash<QWidget *, QString> _addinWidget{};

		Post::PostTreeWidget *_postTreeWidget{};
		Post::PostInfoWidget *_postInfoWidget{};

		PostPlot::PlotTreeWidget *_plotTreewidget{};
	};

}

#endif
